import React from "react";
import "./Button.css";

export default function Button(props) {
  //接受 type 属性
  let { type, children, loading, disabled, onClick, style } = props;

  return (
    <div>
      <button 
        className={"btn btn-" + type} 
        disabled={disabled}
        onClick={onClick}
        style={style}
        >
        <span style={{ marginRight: "5px" }}>{children}</span>
        {loading && (
          <img
            width="16"
            src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhbimg.huabanimg.com%2F7077fb45bc17a504e8316074e17d6fecfebc85e622ec-pkgxTZ_fw658&refer=http%3A%2F%2Fhbimg.huabanimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1660875199&t=6cf256f36986e795f6f0ea41fb4d78aa"
            alt=""
          />
        )}
      </button>
    </div>
  );
}
